<?php
	require("sql_functions.php");
?>  

<html>
<title>GT Project Management Suite</title>
<link href="Style.css" rel="stylesheet" type="text/css">
<body bgcolor="#0FAFAF">  
<center>
<font color="#000000">  
<p><br><br><br>GT Project Manager</p>

<?php
//always start the session before anything else!!!!!!
session_unset();
$_SESSION = array();
unset($_SESSION['user']);
session_destroy();
session_start(); 

if(isset($_POST['username']) && isset($_POST['password']))  
{ 

	$user      = $_POST['username']; //user email
	$password = $_POST['password'];
	
    $result = sql_login($user, $password);
	
	
	//this is where the actual verification happens 
    if($result == 0)
	{ 
		header('Location: dashboard.php');
		$_SESSION['user']=$user;  
		$_SESSION['isAdmin']=0;     
    }
	else if($result == 1)
	{
		header('Location: employee_management.php');
		$_SESSION['user']=$user; 
		$_SESSION['isAdmin']=1; 
	}
	else
	{ 
		$err = 'Incorrect Login' ; 
    } 
    echo "$err";
} 

echo "<html>"; 
echo "<head>"; 
echo "</head>"; 
echo "<body>"; 
echo "<form action=\"\" method=\"POST\">"; 
echo "<p>Username:";  
echo "<input name=\"username\" />"; 
echo "</p>"; 
echo "<p>Password:";  
echo "<input name=\"password\" type=\"password\" />"; 
echo "</p>"; 
echo "<input type=\"submit\" name=\"login\" value=\"Login\" />"; 
echo "</form>"; 
echo "</body>"; 
echo "</html>"; 
?>

</font>
</center>
</body>
</html>
